<template>
	<view class="body" >
		
			
		
		<view class="top">

			<view class="p1" :class="{active:i==1}" @tap="an(1)">
				精选好物
			</view>
			<view class="p2" :class="{active:i==2}" @tap="an(2)">
				好物推荐
			</view>
		</view>

<view class="" v-if="huan">
		<view class="daohang">
			<view class="yuan" v-for="(item,index) in icon" :key="item.index" :class="index==num? 'da':''" @tap="click(index)">
				<image :src="item" mode=""></image>
			</view>
		</view>


		<!-- 产品展示 -->

		<view class="logo" v-for="(item,index) in list" :key="item.id">
		<image :src="item.coverImg" mode="" @tap="goinfo(index)"></image>
		<view class="logo-b">
			<image class="icon1" src="../../static/icons/brand.png" mode=""></image>
	<image class="icon2" src="../../static/icons/zan.png" mode=""></image>
		</view>
	
		</view>


	<view class="di">
		
	</view>
	
	</view>
	
	<view class="body2" v-else>
		<view class="" v-for="item in list2" :key="item.id">
			<image :src="item.bg_img" mode=""></image>
		</view>
	</view>
	
	</view>
	
	
	
</template>

<script>
	import {
		aritlceList,
		seriesAll
	} from "../../util/find/index.js";
	import {
		kind
	} from "../../util/kind/kind.js"
	export default {
		data() {
			return {
				i: 1,
				icon: ['../../static/icons/chuangyi.png',
					'../../static/icons/shipin.png',
					'../../static/icons/fengge.png',
					'../../static/icons/dengju.png'
				],
				num: 0,
				kind:[],
				list:[],
				list2:[],
				huan:true,
			};
		},

		onLoad() {
			kind()
			.then(res => {
				console.log(res)
				this.kind = res.data.data
				
				
				
				aritlceList({
				kindId:this.kind[0].id
			}).then(res => {
				console.log(res)
				this.list = res.data.data.list
			})
			
				
			})
			
			seriesAll()
			.then(res =>{
				console.log(res)
				this.list2 = res.data.data
			})
			
			
			
		},

		methods: {
			an(i) {
				this.i = i;
				if(i==1){
					this.huan=true
				}else{
					this.huan=false
				}
			},

			click(e) {
				this.num = e;
				
				kind()
				.then(res => {
					console.log(res)
					this.kind = res.data.data	
					
					
					aritlceList({
					kindId:this.kind[e].id
				}).then(res => {
					console.log(res)
					this.list = res.data.data.list
				})
				
					
				})
				
				
			},
			
			
			goinfo(val){
				getApp().globalData.fxshuju=this.list[val]
				uni.navigateTo({
					url:`./info/info`
				})
			}



		}




	}
</script>

<style lang="scss" scoped>
	.body {

		background-color: #F1ECE7;
		width: 100%;
		height: 100%;

	}
	// .body2{
	// 	image{
	// 		margin: 0 auto;
	// 	}
	// }

	.top {
		width: 100%;
		height: 88rpx;
		background: #354E44;
		display: flex;
		align-items: center;
		justify-content: center;

		.p1 {
			font-size: 32rpx;
			color: #FFFFFF;
			padding: 10rpx 0;
			margin: 0 10rpx;
			// border-bottom: 1rpx solid #FFFFFF;


		}

		.p2 {
			font-size: 32rpx;
			color: #FFFFFF;
			padding: 10rpx 0;
			margin: 0 10rpx;
			// border-bottom: 1rpx solid #FFFFFF;

		}

		.active {
			border-bottom: 1rpx solid #FFFFFF;
			// box-sizing:border-box;
			// box-sizing: content-box;
		}
	}


	.daohang {
		width: 100%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		margin-top: 40rpx;

		.yuan {
			width: 84rpx;
			height: 84rpx;
			border-radius: 50%;
			background-color: #FFFFFF;
			margin-left: 60rpx;
			text-align: center;

			image {
				margin: 8rpx auto;
				width: 80%;
				height: 80%;

			}
		}

		.da {
			background: #354E44;
			transition: all .3s ease-out;
			transform: scale(1.2);
		}

	}


	.logo {
		width: 674rpx;
		height: 482rpx;
		background-color: #FFFFFF;
		margin: 0 auto;
		margin-top: 46rpx;
		border-radius: 24rpx;
		
		image{
			width: 100%;
			height: 382rpx;
			
			border-radius: 24rpx;
		}
		
		.logo-b{
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: calc(100%-100rpx);
			padding: 0 50rpx;
			.icon1{
			width: 40rpx;
			height: 40rpx;
		}
		
		.icon2{
			width: 40rpx;
			height: 40rpx;
		}
		
		}
		
		
	}
	
	.di{
		width: 100%;
		height: 100rpx;
		
	}
</style>
